var main = [
	[ //表头

		{
			field: 'datetime',
			title: '时间',
		}, {
			field: 'quota',
			title: '额度变化'
		}

	]
];
var data = {};
var fi = 1;
var limit = echarts.init(document.getElementById('limit'));
var load1=layer.load(0, {shade: false});
var load2=layer.load(0, {shade: false});
ajax(api.finance.log, {
	company_id: "{$Think.get.company_id}",
}, 'post').done((res) => {
	layer.close(load1)
	console.log(res)
	table.render({
		elem: '#log',
		cellMinWidth: 80,
		cols: main,
		data: res.data,
		limit: data.pagenum,
		even: true
	});
	if(fi == 1) {
		laypage.render({
			elem: 'page',
			count: res.count,
			layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'],
			theme: '#1E9FFF',
			jump: function(obj, first) {
				if(!first) {
					page = obj.curr
					data.page = page
					pagenum = obj.limit
					data.pagenum = pagenum
					ajaxbuycar(data)
				} else {

				}
			}
		});
		fi = 2
	}
}).fail(() => {
	layer.close(load1)
	Err('请求失败')
})
ajax(api.company.list,{
	where_json:jsonchange({
		company_id:"{$Think.get.company_id}"
	})
}).done((res)=>{
	layer.close(load2)
	console.log(res)
	option = {

	tooltip: {
		trigger: 'item',
		formatter: "{a} <br/>{b} : {c} ({d}%)"
	},
	legend: {
		orient: 'vertical',
		left: 'left',
		data: ['已用额度'+res.data[0].used_quota+'元', '未使用额度'+(res.data[0].unit_quota-res.data[0].used_quota)+'元']
	},
	series: [{
		name: '访问来源',
		type: 'pie',
		radius: '60%',
		center: ['50%', '70%'],
		data: [{
				value: res.data[0].used_quota,
				name: '已用额度'+res.data[0].used_quota+'元'
			},
			{
				value: res.data[0].unit_quota-res.data[0].used_quota,
				name: '未使用额度'+(res.data[0].unit_quota-res.data[0].used_quota)+'元'
			}
		],
		itemStyle: {
			emphasis: {
				shadowBlur: 10,
				shadowOffsetX: 0,
				shadowColor: 'rgba(0, 0, 0, 0.5)'
			}
		}
	}]

};
limit.setOption(option);
}).fail(()=>{
	layer.close(load2)
	Err('请求失败')
})
